<template>
	<view class="summaryLook">
		<view class="date">
			<picker mode="date" fields="month" @change="onEnd">
				<view class="date">
					<text class="my-mgr-10">{{endDate||0}}</text>
					<image src="https://hxc-pay.oss-cn-shenzhen.aliyuncs.com/PILJTnpizY_top_select.png" style="width: 20rpx;height: 20rpx;"></image>
				</view>
			</picker>
		</view>
		<view class="contant_box">
			<template v-if="dev.length > 0">
				<view class="li my-mgt-10" v-for="(item,index) in dev" :key="index">
					<view class="bg_box">
						<view class="bg_pink_rio"><view class="bg_red_rio"></view></view>
					</view>
					<view class="num_box">
						<view class="summ">{{item.totalAmount||0}}</view>
						<view class="txt">{{item.billType||'暂无'}}</view>
					</view>
				</view>
				<view class="li" style="background: none;"></view>
			</template>
			<view style="height: 300rpx;line-height: 300rpx;text-align: center;" v-else>暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {summaryLookApi} from '@/api/home.js'
	export default {
		data() {
			return {
				endDate:null,
				pageIndex:0,
				pageSize:30,
				dev:[],
				total:1,
			};
		},
		created() {
			this.getDate()
			this.getList()
		},
		onReachBottom() {
			this.getList()
		},
		methods:{
			// 获取选中时间
			onEnd(e) {
				this.endDate = e.target.value
				this.total = 1
				this.pageIndex = 0
				this.dev = []
				this.getList()
			},
			getDate() {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				month = month > 9 ? month : '0' + month;
				this.endDate = `${year}-${month}`;
			},
			async getList(){
				if(this.dev.length >= this.total){
					uni.showToast({
						title:"没有更多数据了！",
						icon:'none'
					})
					return 
				}
				let params = {
					billTime: this.endDate,
					pageIndex: this.pageIndex,
					pageSize: this.pageSize,
				}
				uni.showLoading({
					title:'正在加载中....'
				})
				const res = await summaryLookApi(params)
				if(res.statusCode === 200){
					uni.hideLoading()
					this.dev = [...this.dev,...res.data.data];
					this.total = res.data.data.total;
					this.pageIndex++
				}else{
					uni.hideLoading()
					uni.showToast({
						title:res.data.message,
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.summaryLook{
		width: 100%;
		height: 100vh;
		background: #F7F7F7;
		.date{
			width: 100%;
			height: 80rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #FFFFFF;
		}
		.contant_box{
			width: 100%;
			min-height: 200rpx;
			height: auto;
			display: flex;
			align-items: center;
			justify-content: space-evenly;
			flex-wrap: wrap;
			.li{
				width: 337rpx;
				height: 180rpx;
				background: #FFFFFF;
				border-radius: 10rpx;
				.bg_box{
					width: 90%;
					height: 50rpx;
					margin: auto;
					display: flex;
					align-items: center;
					.bg_pink_rio{
						width: 25rpx;
						height: 25rpx;
						background: #FEE0E0;
						border-radius: 50%;
						display: flex;
						justify-content: center;
						align-items: center;
						.bg_red_rio{
							width: 14rpx;
							height: 14rpx;
							background: #F05329;
							border-radius: 50%;
						}
					}
				}
				.num_box{
					width: 75%;
					height: 120rpx;
					margin: auto;
					.summ{
						font-size: 54rpx;
						font-weight: bold;
						color: #000000;
					}
					.txt{
						font-size: 24rpx;
						font-weight: 500;
						color: #666666;
					}
				}
			}
		}
	}
</style>
